#include "ros/ros.h"
#include "turtlesim/Spawn.h"

int main(int argc, char* argv[])
{
    setlocale(LC_ALL, "");
    ros::init(argc, argv, "talker");
    ros::NodeHandle n;
    ros::ServiceClient client = n.serviceClient<turtlesim::Spawn>("/spawn");
    turtlesim::Spawn srv;
    srv.request.x = 1.5;
    srv.request.y = 1.5;
    srv.request.theta = -2.0;
    srv.request.name = "turtule2";
    // ros::service::waitforService("/spawn");
    client.waitForExistence();
    bool flag = client.call(srv); // flag 接收响应状态，响应结果也会被设置进spawan对象
    if (flag) 
    {
        ROS_INFO("successful, %s", srv.response.name.c_str());
    }
    else{
        ROS_INFO("FAILED");
    }
    return 0;
}